package ar.fiuba.test.resources;

import ar.fiuba.logger.LogFormatterInterface;
import ar.fiuba.logger.LogMessageInterface;
import ar.fiuba.logger.LogReporter;

/**
 * The Class StringReporter.
 * 
 * This class implements the string reporter. The string reporter is used for test purposes. DO NOT USE IT AT HOME ;)
 */
public class StringReporter implements LogReporter {

  /** The buffer. */
  static String buffer;

  static LogFormatterInterface formatter;

  /*
   * (non-Javadoc)
   * 
   * @see fiuba.logger.reporter.Reporter#report(java.lang.String)
   */
  @Override
  public void report(LogMessageInterface message) {
    StringReporter.setString(formatter.format(message));
  }

  /**
   * Gets the string.
   * 
   * @return the string
   */
  static public String getString() {
    return buffer;
  }

  /**
   * Sets the string.
   * 
   * @param s
   *            the new string
   */
  static public void setString(String s) {
    StringReporter.buffer = s;
  }

  static public void setFormatter(LogFormatterInterface formatter) {
    StringReporter.formatter = formatter;
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object object) {
    return object instanceof StringReporter;
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode() {
    return (int) Math.random();
  }
}
	